package service.activity

import com.alibaba.fastjson.JSONObject
import controller.vo.ActivityInfoVo
import entity.Activity
import entity.ActivityType

data class ActivityInfo(
        var name: String,
        var profile: String?,
        var startTime: Long?,
        var endTime: Long?,
        var activityType: ActivityType?,
        var location: String?,
        var activityPic: String?
)

fun generateActivityInfo(info: JSONObject): ActivityInfo {
    return ActivityInfo(info.getString("activityName"),
            info.getString("activityProfile"),
            info.getLong("activityStart"),
            info.getLong("activityEnd"),
            ActivityType.valueOf(info.getString("activityKind")),
            info.getString("activityLocation"),
            info.getString("activityPic")
    )
}

fun generateActivityInfo(activity: Activity): ActivityInfo {
    return ActivityInfo(
            activity.activityName,
            activity.activityProfile,
            activity.startTime,
            activity.endTime,
            ActivityType.valueOf(activity.activityType),
            activity.location,
            activity.activityPic
    )
}

fun generateActivityInfo(infoVo: ActivityInfoVo): ActivityInfo {
    return ActivityInfo(
            infoVo.activityName,
            infoVo.activityProfile,
            infoVo.activityStart,
            infoVo.activityEnd,
            infoVo.activityKind,
            infoVo.activityLocation,
            infoVo.activityPic
    )
}